package top.yeyusmile;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.function.BiConsumer;

/**
 * @author 夜雨
 * @Web www.yeyusmile.top
 * @date 2022/4/21 19:46
 */
public class IDCheck {
    public static void main(String[] args) {


        Map<String, Integer> map = new HashMap<>();
        map.put("a",1);
        map.put("b",2);
        map.put("c",3);

        map.forEach(new BiConsumer<String, Integer>() {
            @Override
            public void accept(String s, Integer integer) {

            }
        });


        int[] weight = new int[]{7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
        String checkSums[] = new String[]{"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"};
        System.out.println("请输入身份证前17位:");
        String input = new Scanner(System.in).nextLine();
        if (input.length() != 17) {
            System.out.println("输入错误");
            return;
        }
        char[] id = input.toCharArray();
        int sum = 0;
        for (int i = 0; i < id.length; i++) {
            sum += weight[i] * (id[i] - '0');
        }
        System.out.println(checkSums[sum % 11]);
        System.out.println(input + checkSums[sum % 11]);

    }
}
